This sample is designed to illustrate specific compiler optimizations, features, tools, and programming concepts.

This program computes the integral (area under the curve) of a user-supplied function over an interval in a stepwise fashion. The interval is split into segments, and at each segment position the area of a rectangle is computed whose height is the value of sine at that point and the width is the segment width. The areas of the rectangles are then summed.

The process is repeated with smaller and smaller width rectangles, more closely approximating the true value.

The source for this program also demonstrates recommended Fortran coding practices.

Compile the sample several times using different optimization options:

Read the Intel(R) Fortran Compiler Documentation for more information about these options.

Some of these automatic optimizations use features and options that can restrict program execution to specific architectures.

System Requirements:

Build Instructions

Use the one of the following compiler options:

Windows*: /O1, /O2, /O3  (build [|O1|O2|O3])

Linux* and Mac OS* X: -O1, -O2, -O3 (edit Makefile to select desired optimization level)

The sample is also provided as a Microsoft Visual Studio 2013* solution. It can also be used by Visual Studio 2015* and Visual Studio 2017*.
To set the optimization level in the Visual Studio IDE: right-click the project name and select properties. Set Configuration Properties > Fortran > General > Optimization (/O1, /O2, /O3)